import { request } from "@/utils/request.js";

// 我的 - 一级页面 - 获取可使用订单数量
function getUsableOrder() {
  return request({
    url: "/ht-nonrealtime-gameservice/tbScoreOrder/getUsableOrder",
    method: "GET",
  });
}
// 我的 - 二级页面 - 根据订单状态获取个人订单列表
function listByStatusOrName({
  type,
  orderName = "",
  size =10,
  current = 1,
} = {}) {
  return request({
    url: `/ht-nonrealtime-gameservice/tbScoreOrder/listByStatusOrName?status=${type}&orderName=${orderName}`,
    method: "GET",
  });
}

// 我的 - 三级页面 - 待使用二维码
function showCode(id) {
  return request({
    url: `/ht-nonrealtime-gameservice/tbScoreOrder/showCode?id=${id}`,
    method: "GET",
  });
}

// 我的 - 二级页面 - 添加用户意见反馈
function saveUserOpinion(data) {
  return request({
    url: "/ht-nonrealtime-gameservice/userOpinion/saveUserOpinion",
    method: "POST",
    data,
  });
}

// 我的 - 二级页面 - 二维查询用户（收入、支出）权益分明细
function userGetIntegral(data) {
  return request({
    url: "/ht-nonrealtime-gameservice/integral/log/userGetIntegral",
    method: "POST",
    data,
  });
}

// 我的 - 二级页面 - 二维获取用户可用权益分
function getUserUsableIntegral(data) {
  return request({
    url: "/ht-nonrealtime-gameservice/integral/getUserUsableIntegral",
    method: "POST",
    data,
  });
}

//获取用户信息
const getUserInfoApi = () => {
  return request({
    headers: {
      isToken: true,
    },
    url: "/ht-user/user/getUserInfo",
    method: "POST",
  });
};

//更新简介
const updateUserBaselnfo = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: "/ht-user/user/updateUserBaseInfo",
    method: "POST",
    data: data,
    // responseType: 'arraybuffer',
  });
};

//实名认证
const realNameAuth = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: "/ht-user/user/realNameAuth",
    method: "POST",
    data: data,
    // responseType: 'arraybuffer',
  });
};
//企业荣誉
const getEnterpriseHonorByEnterprise = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-user/enterpriseHonor/getEnterpriseHonorByEnterprise?enterpriseId=${data}`,
    method: "GET",
  });
};
//个人荣誉
const getPersonalHonorList = () => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-user/userHonor/getUserHonorInfoList`,
    method: "GET",
  });
};

//消息
const tbScoreOrder = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-nonrealtime-gameservice/tbScoreOrder/message`,
    method: "GET",
    data: data,
  });
};

const getUserXhbTotalJbLogs = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-nonrealtime-gameservice/publish/getUserXhbTotalJbLogs`,
    method: "POST",
    data: data,
  });
};
//消息已读或删除

const updateMessage = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-nonrealtime-gameservice/tbScoreOrder/updateMessage?id=${data.id}&&tsoIsRead=${data.tsoIsRead}`,
    method: "POST",
  });
};
//优惠券
const getRollNum = (data) => {
  return request({
    headers: {
      isToken: true,
    },
    url: `/ht-nonrealtime-gameservice/tbScoreOrder/pageByRoll`,
    method: "GET",
    data: data,
  });
};

export const getAppEnterpriseList = async (query) => {
  let data = await request({
    headers: {
      isToken: true,
    },
    url: "/ht-user/enterprise/getAppEnterpriseList",
    method: "POST",
    data: query,
  });
  return data;
};

export const joinEnterpriseApi = (enterpriseId) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/addUserBindEnterpriseIndustry`,
    method: "POST",
    data: {enterpriseId}
  })
}
export const getUserDiscountApi = () => {
  return request({
      url: `/ht-nonrealtime-gameservice/honorScore/getUserDiscount`,
      method: 'GET',
  })
}
//加入企业
export const addUserBindEnterpriseIndustry = async (query) => {
  let data = await request({
    headers: {
      isToken: true,
    },
    url: "/ht-user/enterpriseEmpCheck/addUserBindEnterpriseIndustry",
    method: "POST",
    data: query,
  });
  return data;
};

/**
 * 上传头像
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const upLoadAvatarApi = (data) => {
  const queryString = `avatar=${encodeURIComponent(data.avatar)}`;
  return request({
    url: `/ht-user/user/uploadAvatar?${queryString}`,
    headers: {
      "content-type": "application/x-www-form-urlencoded",
    },
    method: "GET",
  });
};

/**
 * 更新用户信息
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const updateUserInfoApi = (data) => {
  return request({
    url: "/ht-user/user/updateUserBaseInfo",
    method: "POST",
    data,
  });
};
//邀请加入企业
export const generateTokenLink = (data) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/shareUserAddEnterprise`,
    method: "GET",
  });
};

/**
 * 获取相互帮操作日志
 * @returns {Promise | Promise<unknown>}
 */
export const getXhbOperationsLogsAPi = () => {
  return request({
    url: "/ht-nonrealtime-gameservice/publish/getUserXhbOperationLogs",
    methods: "GET",
  });
};

/**
 * 相互帮信息操作
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const xhbOperationMsgStatusAPi = (data) => {
  return request({
    url: "/ht-nonrealtime-gameservice/publish/xhbOperationMsgStatus",
    method: "GET",
    data,
  });
};

/**
 * 获取上传资料消息列表
 * @param type
 * @returns {Promise | Promise<unknown>}
 */
export const getHonorCheckLogs = (type) => {
  return request({
    url: "/ht-user/honorCheck/getHonorCheckLogs",
    method: "GET",
    data: type,
  });
};

export const updateUploadMsgStatus = (data) => {
  return request({
    url: "/ht-user/honorCheck/updateUploadMsgStatus",
    method: "GET",
    data,
  });
};

// 管理企业数据接口
//企业详情
export const getAppEnterpriseBaseInfo = (id) => {
  return request({
    url: `/ht-user/enterprise/getAppEnterpriseBaseInfo?enterpriseId=${id}`,
    method: "POST",
  });
};
//企业修改
export const updateEnterpriseBaseInfo = (data) => {
  return request({
    url: `/ht-user/enterprise/updateEnterpriseBaseInfo`,
    method: "POST",
    data: data,
  });
};
//员工列表
export const getEnterpriseEmpPageList = (data) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/getEnterpriseEmpPageList`,
    method: "POST",
    data: data,
  });
};
//员工列表移除
export const removeEnterpriseEmp = (id) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/removeEnterpriseEmp?userId=${id}`,
    method: "GET",
  });
};
//加入申请列表
export const getUserBindEnterpriseCheckPageList = (data) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/getUserBindEnterpriseCheckPageList`,
    method: "POST",
    data: data,
  });
};
//加入申请审核
export const updateCheckStatus = (data) => {
  return request({
    url: `/ht-user/enterpriseEmpCheck/updateCheckStatus`,
    method: "POST",
    data: data,
  });
};

export const getUploadDataReviewStageListApi = (data) => {
  return request({
    url: "/ht-user/honorCheck/getHonorCheckLogs",
    method: "GET",
    data,
  });
};

// 加入企业
// 查询标签
export function grantEnterpriseFindLabel()  {
    return request({
        url: '/ht-user/enterprise/grantEnterpriseFindLabel',
        method: 'GET',
    })
}
// 申请管理员
const applyManagerCheck = (data)=>{
    return request({
        url: '/ht-nonrealtime-gameservice/applyManager/applyManagerCheck',
        method: 'POST',
		data: data,
    })
}

// 注销相关 Start
/**
 * 获取幂等值
 */
export const getPowerEquivalenceApi = data => {
  return request({
    url: '/ht-user/user/getUUID',
    method: 'GET',
    data
  })
}

/**
 * 获取短信验证码
 * @param data
 * @returns {Promise | Promise<unknown>}
 */
export const getVerificationCodeApi = data => {
  return request({
    url: '/ht-user/user/getSms',
    method: 'POST',
    data
  })
}

export const applySignOutApi = data => {
  return request({
    url: '/ht-user/user/userCancelAnAccount',
    method: 'GET',
    data
  })
}
// 注销相关 End

// 申请管理员审核api
export const getApplyManagerLogApi = async () => {
  return request({
    url: '/ht-nonrealtime-gameservice/applyManager/getUserApplyManagerLog',
    method: 'POST'
  })
}

/**
 * 获取用户荣耀权益
 * @returns {Promise<unknown>}
 */
export const getUserHonorRightsApi = () => {
  return request({
    url :'/ht-nonrealtime-gameservice/honorScore/getUserDiscount',
    method:'GET',
  })
}

/**
 * 管理员账号获取消息提示红点
 * @returns {Promise<unknown>}
 */
export const getManagerMsgBadgeApi = () => {
  return request({
    url: '/ht-user/enterpriseEmpCheck/applyForUnauditedCount',
    method: 'POST'
  })
}


export const getDiscountsRulesApi = () => {
  return request({
    url: '/ht-nonrealtime-gameservice/preferentialRules/getPreferentialRulesList',
    method: 'POST'
  })
}
export const getConfigEnterpriseFieldsApi = (type) => {
  return request({
    url: `/ht-nonrealtime-gameservice/configFields/getConfigEnterpriseFields?type=${type}`,
    method: 'GET'
  })
}
/**
 * 检测是否绑定手机
 * @returns {*}
 */
export const checkIsExistPhoneApi = () => {
  return request({
      url:'/ht-user/user/checkIsExistPhone',
      method: 'GET'
  })
}
/**
 * 检测是否绑定手机
 * @returns {*}
 */
export const getUserMsgTotalApi = () => {
  return request({
      url:'/ht-nonrealtime-gameservice/userMsgNotice/getUserMsgTotal',
      method: 'GET'
  })
}
export {
  /** 我的 - 一级页面 - 首页 */
  getUserInfoApi,
  /** 我的 - 一级页面 - 可使用数量 */
  getUsableOrder,
  /**我的 - 二级页面 - 根据订单状态获取个人订单列表 */
  listByStatusOrName,
  /** 我的 - 二级页面 - 获取可使用优惠卷数量 */
  // getRollNum,
  /** 我的 - 二级页面 - 意见反馈 */
  saveUserOpinion,
  /** 我的 - 三级页面 - 待使用二维码 */
  showCode,
  /** 我的 - 二级页面 - 二维查询用户（收入、支出）权益分明细 */
  userGetIntegral,
  /** 我的 - 二级页面 - 二维获取用户可用权益分 */
  getUserUsableIntegral,
  updateUserBaselnfo,
  realNameAuth,
  getEnterpriseHonorByEnterprise,
  getPersonalHonorList,
  tbScoreOrder,
  getUserXhbTotalJbLogs,
  updateMessage,
  getRollNum,
  applyManagerCheck
};
